package com.example.demo;

import com.example.demo.entity.Supplier;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SupplierJPARepository extends JpaRepository<Supplier,Long> {

    @Modifying
    @Query(value = "INSERT INTO goods_supplier (goods_id,supplier_id) VALUES (?1,?2)",nativeQuery = true)
    public void addProductSupplier(long goodsId,long supplierId);

    @Query(value = "Select s From supplier where (?1=id）and(?2=name)and(?3=phoneNumber)",nativeQuery = true)
    List<Supplier> findAll(Specification<Supplier> specification);
}